<template>
	<view>
		<u-tabs :list="list" :is-scroll="false" :current="current" @change="change"></u-tabs>
		<view class="reserve-list" style="padding: 20rpx;">
			<view class="order-item" v-for="item in dataList">
				<view class="top">
					<text>{{item.categoryName}}</text>
					<view class="status center" @click="to">预约</view>
				</view>
				<view class="id">就诊时间：2023-3-01 10:30</view>
				<view class="date" v-if="item.type === 2">门诊类型：普通号</view>
				<view class="date" v-else>门诊类型：专家号</view>
				<view class="money">金额： {{item.money}}</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				list: [{
						name: '专家号',
					},
					{
						name: '普通号'
					},
				],
				current: 0,
				dataList: [],
				type: ''
			};
		},
		onLoad(option) {
			this.type = option.type
			this.getData(option.type)
		},
		methods: {
			change(index){
				this.current = index
				this.getData(this.type)
			},
			getData(type){
				this.$request({
					url: '/prod-api/api/hospital/category/list',
					data: {
						type: this.current + 1
					}
				}).then(res => {
					console.log(res)
					this.dataList = res.rows.filter(item => item.categoryName === type)
					console.log(this.dataList)
				})
			},
			to(){
				uni.navigateTo({
					url:'/pages/reserve-result/reserve-result?type=' + this.dataList.type
				})
			}
		}
	}
</script>

<style lang="scss">
page{
	background-color: #f7f7f7;
	view{
		.order-item{
			padding: 20rpx;
			background-color: #fff;
			.top{
				display: flex;
				flex-direction: row;
				justify-content: space-between;
				align-items: center;
				padding: 20rpx 0;
				border-bottom: 4rpx solid #e4e7ed;
				text{
					color: #2979ff;
					font-weight: bold;
					font-size: 32rpx;
				}
				.status{
					width: 120rpx;
					height: 60rpx;
					font-size: 26rpx;
					color: white;
					background-color: #2979ff;
					border-radius: 10rpx;
				}
			}
			.id{
				padding: 20rpx 0;
			}
			.date{
				padding: 10rpx 0;
			}
			.money{
				color: #ff9900;
				font-weight: bold;
				font-size: 32rpx;
			}
		}
	}
}
</style>